package com.du.service.impl;

import com.du.dao.BaseDAO;
import com.du.dao.UserDAO;
import com.du.dao.impl.UserDAOImpl;
import com.du.pojo.User;
import com.du.service.UserService;

/**
 * @author : DuJiabao
 * @Date : 2021/1/28 21:18
 * @Project : bookstore
 * @File : null.java
 * @Desc :
 */
public class UserServiceImpl implements UserService {
    UserDAO userDAO = new UserDAOImpl();

    @Override
    public int registerUser(User user) {
        return userDAO.saveUser(user);
    }

    @Override
    public User loginUser(User user) {
        return userDAO.queryUserByUsernameAndPassword(user.getUsername(), user.getPassword());
    }

    @Override
    public boolean existsUser(String username) {
        return userDAO.queryUserByUsername(username) != null;
    }
}
